Component({
	properties: {
		// 这里定义了innerText属性，属性值可以在组件使用时指定
		innerText: {
			type: String,
			value: 'default value',
		},
		finderUserName:{
			type: String,
			value: '',
		}
	},
	data: {
		// 这里是一些组件内部数据
		someData: {},
		feedId: '', //直播 feedId
		// finderUserName: 'sphxF8lPV1kQgIP',
		isRepeat: false,
	},
	lifetimes: {
		attached: function() {
			this.customMethod()
		},
	},
	methods: {
		// 获取直播间id
		customMethod: function() {
			// console.log('this.properties.finderUserName',this.properties.finderUserName)
			var that = this
			wx.getChannelsLiveInfo({
				finderUserName: this.properties.finderUserName,
				success: function(res) {
					// console.log('成功', res);
					that.setData({
						feedId: res.feedId
					})
				},
				fail: function(res) {
					console.log('认证失败', res);
				}
			});
		},
		//打开直播间
		openLive() {
			if(this.data.isRepeat){ //防重复
				return
			}
			this.data.isRepeat = true
			wx.openChannelsLive({
				finderUserName: this.properties.finderUserName,
				feedId: this.data.feedId,
				success: res => {
					console.log(res)
					this.data.isRepeat = false
				},
				fail: res => {
					console.log(res)
					this.data.isRepeat = false
				}
			});
		},
	}
})